﻿Imports System
Imports System.Collections
Imports System.Collections.Generic

Namespace System.Workflow.ComponentModel
    Friend NotInheritable Class BindRecursionContext
        ' Methods
        Public Sub Add(ByVal activity As Activity, ByVal bind As ActivityBind)
            If (activity Is Nothing) Then
                Throw New ArgumentNullException("activity")
            End If
            If (bind Is Nothing) Then
                Throw New ArgumentNullException("bind")
            End If
            If (Me.activityBinds.Item(activity) Is Nothing) Then
                Me.activityBinds.Item(activity) = New List([Of] ActivityBind)
            End If
            DirectCast(Me.activityBinds.Item(activity), List([Of] ActivityBind)).Add(bind)
        End Sub

        Public Function Contains(ByVal activity As Activity, ByVal bind As ActivityBind) As Boolean
            If (activity Is Nothing) Then
                Throw New ArgumentNullException("activity")
            End If
            If (bind Is Nothing) Then
                Throw New ArgumentNullException("bind")
            End If
            If (Not Me.activityBinds.Item(activity) Is Nothing) Then
                Dim list As List([Of] ActivityBind) = [TryCast](Me.activityBinds.Item(activity),List([Of] ActivityBind))
                Dim bind2 As ActivityBind
                For Each bind2 In list
                    If (bind2.Path = bind.Path) Then
                        Return True
                    End If
                Next
            End If
            Return False
        End Function


        ' Fields
        Private activityBinds As Hashtable = New Hashtable
    End Class
End Namespace

